//layout box
#include "RelativeBox.h"

RelativeBox::RelativeBox()
{
}

RelativeBox::~RelativeBox()
{
}

void RelativeBox::UpdateLayout()
{
	vec2 size;
	size.x = pos.x;
	size.y = pos.y;
	vec2 curPos;
	float maxHeight = 0;
	for (int i = 0; i < childs.size(); i++)
	{
		Control* cld = childs[i].second;
		cld->pos.x = curPos.x;
		cld->pos.y = curPos.y;
		curPos.x += cld->size.x;
		if (maxHeight < cld->size.y)
		{
			maxHeight = cld->size.y;
		}
		if (curPos.x > size.x)
		{
			curPos.x = 0;
			curPos.y += 10;
		}
	}
}
void RelativeBox::Draw()
{
	for (int i = 0; i < childs.size(); i++)
	{
		Control* cld = childs[i].second;
		cld->Draw();
	}

}

